﻿/*
 * ©2009-2010 XELF
 * http://xelf.info
 */

namespace XELF.Framework {

	public partial struct Vector2 {
		/// <summary>
		/// 反射方向ベクトル。-2 (N . U) N + U
		/// </summary>
		/// <param name="vector">入射方向ベクトル</param>
		/// <param name="normal">法線ベクトル</param>
		/// <param name="result"></param>
		public static void Reflect(ref Vector2 vector, ref Vector2 normal, out Vector2 result) {
			float a;
			Vector2.Dot(ref normal, ref vector, out a);
			Madd(ref normal, a * -2, ref vector, out result);
		}
	}

	public partial struct Vector3 {
		/// <summary>
		/// 反射方向ベクトル。-2 (N . U) N + U
		/// </summary>
		/// <param name="vector">入射方向ベクトル</param>
		/// <param name="normal">法線ベクトル</param>
		/// <param name="result"></param>
		public static void Reflect(ref Vector3 vector, ref Vector3 normal, out Vector3 result) {
			float a;
			Vector3.Dot(ref normal, ref vector, out a);
			Madd(ref normal, a * -2, ref vector, out result);
		}
	}

}
